﻿@model PagedList<ADZ_JingjiaConfig>
@{
    ViewBag.Title = "竞价配置列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    JingjiaConfigQueryModel paramModel = new JingjiaConfigQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (JingjiaConfigQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("getconfiglist", "jingjia")" method="get">
    <div class="form_query">
        <div>
            竞价状态：
            <select id="jingjia_config_satus" name="jingjia_config_satus">
                <option value="-10">全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add(((int)JingjiaConfigStatus.Default).ToString(), "未开始");
                    dc.Add(((int)JingjiaConfigStatus.InProgress).ToString(), "进行中");
                    dc.Add(((int)JingjiaConfigStatus.Finished).ToString(), "已结束");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.jingjia_config_satus.ToString());
            </select>&nbsp;

        </div>
        <div>
            竞价开始时间：
            <input type="text" name="beg_time" class="calendar calendar-time" id="beg_time" value="@paramModel.beg_time.ToString(1)"> - <input type="text" name="end_time" class="calendar calendar-time" id="end_time" value="@paramModel.end_time.ToString(1)">&nbsp;
        </div>
        <div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("AddConfig","jingjia")'">新增竞价配置</button>
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>编号</th>
            <th>竞价配置名称</th>
            <th>是否在App展示</th>
            <th>竞价状态</th>
            <th>竞价包数量</th>
            <th>保证金额</th>
            <th>报名人数</th>
            <th>开始时间</th>
            <th>结束时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
    <tr class="@HtmlPagerHelper.TrClass(index)">
        <td>@m.jingjia_config_id</td>
        <td>@m.jingjia_config_name</td>
        <td>
            @if (m.is_show == 0)
            {
                <info>不展示</info>
            }
            else
            {
                <info class="green">展示中</info>
            }
        </td>
        <td>
            @if (m.jingjia_config_satus == (int)JingjiaConfigStatus.Default)
            {
                <info>未开始</info>
            }
            else if (m.jingjia_config_satus == (int)JingjiaConfigStatus.InProgress)
            {
                <info class="green">进行中</info>
            }
            else if (m.jingjia_config_satus == (int)JingjiaConfigStatus.Finished)
            {
                <info class="red">已结束</info>
            }
        </td>
        <td>
            @{
                @dbcontext.ADZ_JingjiaMaster.Count(t => t.jingjia_config_id == m.jingjia_config_id && t.is_del == 0);
            }
            <a href="@Url.Action("GetList", "jingjia", new { jingjia_config_id = m.jingjia_config_id})">查看</a>
        </td>
        <td>￥@m.baozheng_price.ToString("N2")</td>
        <td>@m.baoming_counts <a href="/jingjia/BaomingGetList?jingjia_config_id=@m.jingjia_config_id">查看</a></td>
        <td>@m.begin_time.ToString(1)</td>
        <td>@m.end_time.ToString(1)</td>
        <td>
            <a href="@Url.Action("AddConfig", "jingjia", new { id = m.jingjia_config_id})">编辑</a>

            @if (m.is_show == 0)
            {
                <a href="javascript:void(0);" onclick="PublishConfig(@m.jingjia_config_id,1)">展示到App</a>
            }
            @if (m.is_show == 1)
            {
                <a href="javascript:void(0);" onclick="PublishConfig(@m.jingjia_config_id,0)">移除展示</a>
            }
        </td>
    </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>


<script>

    reloadHandler = function () {
        window.location.reload();
    }
    
    function PublishConfig(jingjia_config_id, up_down) {
        var msg = "确认将此竞价展示到APP端吗？";
        if (up_down != 1) {
            msg = "确认经此竞价信息从APP端移除吗？";
        }
        BUI.Message.Show({
            title: '提示',
            msg: msg,
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("PublishConfig", "jingjia")";
                        parameter = {
                            jingjia_config_id: jingjia_config_id,
                            up_down: up_down
                        };
                      $.post(url, parameter, function (result) {
                                    ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
              }

            ]
        });
    }
</script>